package cz.gelion.shylock.invoice.web

import org.apache.wicket.behavior.Behavior
import org.apache.wicket.markup.html.WebPage
import org.apache.wicket.request.component.IRequestablePage
import scala.beans.BeanProperty
import org.apache.wicket.markup.html.basic.Label
import org.apache.wicket.model.Model
import cz.gelion.shylock.invoice.Log
import cz.gelion.shylock.invoice.web.comp.ModalDataWindow
import org.apache.wicket.ajax.AjaxRequestTarget
import org.apache.wicket.Component

abstract class ShylockInvoicePage extends WebPage with Log {

  log.debug("init:" + this)
  
  def em = Application.em
  
  def name:String
  
  def modalContentId = modal.getContentId
  
  val modal = new ModalDataWindow("modal")
  add(modal)
  
   
   add(new Label("name", new Model[String](){
     override def getObject:String = name
   }));
  
  
  
  def openModal(target:AjaxRequestTarget, component:Component, closing:AjaxRequestTarget => Unit):Unit = {
    openModal(target,component)
    modal.close = closing
  }
  
  def openModal(target:AjaxRequestTarget, component:Component):Unit = {
    modal.setContent(component);
    modal.show(target)
  }
  
}